/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FramePrincipal.java
 *
 * Created on 18/07/2011, 14:20:23
 */
package br.com.GUI;

import br.com.GUI.cadastro.*;
import br.com.GUI.caixa.FrameMovimento;
import br.com.GUI.relatorio.FrameRelCaixa;
import br.com.GUI.relatorio.RelMovEntidade;
import br.com.GUI.relatorio.FrameRelSaldos;
import br.com.dao.ChequeDao;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;

/**
 *
 * @author Kauane
 */
public class FramePrincipal extends javax.swing.JFrame {

    String loginp;
    String userp;
    int codusu;
    JDesktopPane DESKTOP;

    public FramePrincipal(String login, String user, int cod) {
        initComponents();

        //System.out.println(user); 
        jLabel1.setText(" Usuário: " + login + " Tipo: " + user);
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        Date date = new Date();

        if (user.equals("Administrador")) {
            userp = 0 + "";
        } else {
            userp = 1 + "";
        }

        jLabel2.setText(dateFormat.format(date));
        loginp = login;
        codusu = cod;

     
        if (user.equals("Usuario")) {
            jMenuItemUsuario.setVisible(false);
            jMenuItemCaixa.setVisible(false);
            jMenuItemHistorico.setVisible(false);
        }
    }

    public FramePrincipal() {
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        MenuArquivo = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        MenuCaixa = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        MenuRelatorios = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItemEntidade = new javax.swing.JMenuItem();
        jMenuItemCaixa = new javax.swing.JMenuItem();
        jMenuItemHistorico = new javax.swing.JMenuItem();
        jMenuItemBanco = new javax.swing.JMenuItem();
        jMenuItemUsuario = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItemAtualizaBanco = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("UNIRC");

        jLabel1.setText("jLabel1");

        jLabel2.setText("jLabel2");

        MenuArquivo.setText("Arquivo");

        jMenuItem9.setText("Sair");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        MenuArquivo.add(jMenuItem9);

        jMenuBar1.add(MenuArquivo);

        MenuCaixa.setText("Caixa");
        MenuCaixa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuCaixaActionPerformed(evt);
            }
        });

        jMenuItem10.setText("Movimento");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        MenuCaixa.add(jMenuItem10);

        jMenuBar1.add(MenuCaixa);

        MenuRelatorios.setText("Relatorios");

        jMenuItem1.setText("Ver Relatorios");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        MenuRelatorios.add(jMenuItem1);

        jMenuItem2.setText("Livro Caixa");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        MenuRelatorios.add(jMenuItem2);

        jMenuItem4.setText("Movimento Bancario");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        MenuRelatorios.add(jMenuItem4);

        jMenuItem5.setText("Saldo Bancario");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        MenuRelatorios.add(jMenuItem5);

        jMenuBar1.add(MenuRelatorios);

        jMenu1.setText("Cadastro");

        jMenuItemEntidade.setText("Cliente/Fornecedor");
        jMenuItemEntidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemEntidadeActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemEntidade);

        jMenuItemCaixa.setText("Caixa");
        jMenuItemCaixa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCaixaActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemCaixa);

        jMenuItemHistorico.setText("Historico Padrão");
        jMenuItemHistorico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHistoricoActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemHistorico);

        jMenuItemBanco.setText("Banco");
        jMenuItemBanco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemBancoActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemBanco);

        jMenuItemUsuario.setText("Usuário");
        jMenuItemUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemUsuarioActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemUsuario);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Configuracoes");

        jMenuItemAtualizaBanco.setText("Atualizar Banco");
        jMenuItemAtualizaBanco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAtualizaBancoActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemAtualizaBanco);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(414, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(35, 35, 35)
                .addComponent(jLabel2)
                .addGap(19, 19, 19))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(392, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItemHistoricoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHistoricoActionPerformed
        // TODO add your handling code here:
        FrameHistorico INTERNO = new FrameHistorico();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItemHistoricoActionPerformed

    private void jMenuItemBancoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBancoActionPerformed
        // TODO add your handling code here:
        FrameBanco INTERNO = new FrameBanco();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItemBancoActionPerformed

    private void jMenuItemUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUsuarioActionPerformed
        // Cad Usuario
        FrameUsuario INTERNO = new FrameUsuario();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItemUsuarioActionPerformed

    private void jMenuItemCaixaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCaixaActionPerformed
        // TODO add your handling code here:
        FrameCaixa INTERNO = new FrameCaixa();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
    }//GEN-LAST:event_jMenuItemCaixaActionPerformed

    private void jMenuItemEntidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEntidadeActionPerformed
        // Cad Cliente/Fornecedor
        FrameEntidade INTERNO = new FrameEntidade();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItemEntidadeActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        FrameRelSaldos INTERNO = new FrameRelSaldos();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        RelMovEntidade INTERNO = new RelMovEntidade();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        FrameRelCaixa INTERNO = new FrameRelCaixa();
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
}//GEN-LAST:event_jMenuItem2ActionPerformed

    private void MenuCaixaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuCaixaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_MenuCaixaActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        //Movimento de Caixa
        FrameMovimento INTERNO = new FrameMovimento(loginp, userp, codusu);
        INTERNO.setLocationRelativeTo(INTERNO);
        INTERNO.setVisible(true);
        //setLocationRelativeTo
}//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItemAtualizaBancoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAtualizaBancoActionPerformed
        // TODO add your handling code here:
        ChequeDao cdao = new ChequeDao();
        if(cdao.MudaChequeNull()){
           JOptionPane.showMessageDialog(null, "Alterado Banco com sucesso!"); 
        } 
    }//GEN-LAST:event_jMenuItemAtualizaBancoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu MenuArquivo;
    private javax.swing.JMenu MenuCaixa;
    private javax.swing.JMenu MenuRelatorios;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JMenuItem jMenuItemAtualizaBanco;
    private javax.swing.JMenuItem jMenuItemBanco;
    private javax.swing.JMenuItem jMenuItemCaixa;
    private javax.swing.JMenuItem jMenuItemEntidade;
    private javax.swing.JMenuItem jMenuItemHistorico;
    private javax.swing.JMenuItem jMenuItemUsuario;
    // End of variables declaration//GEN-END:variables
}
